<?php
session_start();
if (!isset($_SESSION['admin'])) { header('Location: index.php'); exit; }
$dataFile = '../data/links.json';
if ($_POST) {
    file_put_contents($dataFile, json_encode($_POST, JSON_UNESCAPED_UNICODE|JSON_PRETTY_PRINT));
    $msg = '保存成功';
}
$info = file_exists($dataFile) ? json_decode(file_get_contents($dataFile), true) : [];
?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>其它链接管理</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/bootstrap/5.3.2/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container py-4">
    <h4 class="mb-3">其它链接管理</h4>
    <?php if(isset($msg)) echo '<div class="alert alert-success">'.$msg.'</div>'; ?>
    <form method="post" class="bg-white p-4 rounded shadow-sm">
        <div class="mb-3">
            <label class="form-label">帮助中心链接</label>
            <input name="help" class="form-control" value="<?=htmlspecialchars($info['help']??'')?>">
        </div>
        <div class="mb-3">
            <label class="form-label">用户协议链接</label>
            <input name="agreement" class="form-control" value="<?=htmlspecialchars($info['agreement']??'')?>">
        </div>
        <div class="mb-3">
            <label class="form-label">隐私政策链接</label>
            <input name="privacy" class="form-control" value="<?=htmlspecialchars($info['privacy']??'')?>">
        </div>
        <div class="d-flex justify-content-end gap-3 mt-4">
            <button type="submit" class="btn btn-primary btn-lg px-5">保存</button>
            <a href="project_dashboard.php?pid=<?=$_GET['pid']?>" class="btn btn-outline-secondary btn-lg px-5">返回</a>
        </div>
    </form>
</div>
</body>
</html> 